<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var strs = ["flower","flow","flight"];
        var longestCommonPrefix = function(strs) {
            if(strs.length==0){
                return "";
            }
            var rows = strs.length;
            var clos = strs[0].length;
            for(var i =0;i<clos;i++){
                var firstChar = strs[0][i]
                for(var j =1;j<rows;j++){
                    if(strs[j].length==i||strs[j][i]!=firstChar){
                        return strs[0].substr(0,i)
                    }
                }
            }
        return strs[0]
        }
        var res = longestCommonPrefix(strs)
        console.log(res)
    </script>
</body>
</html>